package org.hry.netty.protobuf;

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandlerAdapter;
import io.netty.util.ReferenceCountUtil;

/**
 * @Desc
 * @Author houry
 * @Date 2021/2/20 15:43
 **/
public class ProtoBufServerHandlerw extends ChannelInboundHandlerAdapter {


    @Override
    public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
        BarrageProto.Barrage barrage = (BarrageProto.Barrage) msg;
        if ("robot".equals(barrage.getMsgType())) {
            System.out.println("robot--------" + msg.toString());
        } else {
            System.out.println(ReferenceCountUtil.release(msg));
            ctx.fireChannelRead(msg);
        }
    }
}
